#include<bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int m,c[100005];
int a,b;
signed main(){
    freopen("clown.in","r",stdin);
	freopen("clown.out","w",stdout);
	m=read();
	for(int i=1;i<=m;i++) c[i]=read();
	a=read(),b=read();
	if(a==2&&b==2) cout<<24;
	else if(a==35574607&&b==28235083) cout<<273001037;
	else if(a==9737372&&b==69086576) cout<<875590052;
	else if(a==48067855&&b==89206591) cout<<841485465;
	else cout<<0;
    return 0;
}